package com.yhy.mapper;

import com.yhy.model.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentMapper {
    @Select("SELECT * FROM students")
    List<Student> findAll();

    @Insert("INSERT INTO students(name, age, gender, email, phone, address) VALUES(#{name}, #{age}, #{gender}, #{email}, #{phone}, #{address})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Student student);

    @Update("UPDATE students SET name=#{name}, age=#{age}, gender=#{gender}, email=#{email}, phone=#{phone}, address=#{address} WHERE id=#{id}")
    void update(Student student);

    @Delete("DELETE FROM students WHERE id=#{id}")
    void deleteById(Long id);

    @Select("SELECT * FROM students WHERE id=#{id}")
    Student findById(Long id);
}
